#include <iostream>
#include <algorithm>
using namespace std;

//https://ac.nowcoder.com/acm/problem/26221

typedef pair<int, int> PII;

const int N = 2e5 + 10;
int n, k;
PII arr[N];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> arr[i].first;
    for (int i = 0; i < n; i++) cin >> arr[i].second;

    sort(arr, arr + n, [&](const PII& a, const PII& b)
        {
            if (a.second != b.second) return a.second > b.second;
            else return a.first < b.first;
        });

    long long s = 0, t = 0;
    for (int i = 0; i < k; i++)
    {
        s += arr[i].first;
        t += arr[i].second;
    }

    cout << s << ' ' << t << endl;

    return 0;
}